<?php
  if(!isset($_GET['user_id']))
  {
	header('Location:index.php?module=user_manager');
  }
  else
  {
	$showPage = false;
	if($authority->getAuthority('edit_user',$_SESSION['id']) == true)
	{
		
		if($_POST)
		{

			if($db->sql(" UPDATE snm_user SET name_surname = '".$db->escape($_POST['name_surname'])."' , global_id = '".$db->escape($_POST['global_id'])."',  authority_group_id = ".intval($_POST['authority_group_id'])." WHERE id = ".intval($_GET['user_id'])))
			{
				if($_POST['password'] != "")
				{
					$db->sql(" UPDATE snm_user SET password = '".md5($_POST['password'])."'  WHERE id=".intval($_GET['user_id']));
				}
				$hata['sonuc'] = true;
				$hata['aciklama'] = ' User Edit Completed.';		   
			}
			else
			{
				$hata['sonuc'] = false;
				$hata['aciklama'] = ' SQL ERROR!'; 
			}
		}
		
		
		$groupsArray = $authority-> getGroup();
		
		$showPage = true;
		$user = $userClass->getUserDetail($_GET['user_id']);

	}
	else
	{
		$hata['sonuc'] = false;
		$hata['aciklama'] = ' <strong>Error!</strong> you cant login this page!.';
	}
  }
  
  include "template/edit_user.php";
?>
